/********************************************************************

Write Date: 2011/04/10
Author: Deng Nianchen
>>>> Add class ConfigManager to provide read / write config files

Modify Date: 2011/07/29
Author: Deng Nianchen
>>>> Add support for multi config file by move _attrs to a new class Config

Modify Date: 2011/12/22
Author: Deng Nianchen
>>>> Add support for base path, which is a common prefix of the path of
	 configuration file
*********************************************************************/
#ifndef CONFIG_MANAGER_H
#define CONFIG_MANAGER_H
#include "Singleton.hpp"
#include "OOPException.hpp"
#include "ConfigExceptions.hpp"
#include "OOPString.h"
#include "Config.h"
#include "OOPPtr.hpp"


_OOPUTILS_BEGIN



/**************************************************************************************************
 * <summary> Purpose: Provide support for config files.
 *					 A config file is a file with many lines of text. each line 
 *					 contains a key and a value, which is joined by '='.
 *					 An example file is as follow:
 *					 windowWidth=800
 *					 windowHeight=600
 * 					 Thread-Safe: the class is not thread-safe. </summary>
 * 
 * <remarks>  Deng Nianchen, 2011/04/10. </remarks>
 **************************************************************************************************/

class _EXPORT_UTILS_CLASS ConfigManager : public Singleton< ConfigManager >
{

	friend class Singleton< ConfigManager >;

private:

	OOPString _basePath;

	ConfigManager ();

public:

	OOPPtr< Config > load (const OOPString & filePath)
			throw (ReadConfigFileException);

	void save (OOPPtr< Config > pConfigToSave,
			const OOPString & filePath = OOPString ())
			throw (WriteConfigFileException);

	void setBasePath (const OOPString& basePath);

	OOPString& getBasePath ();

	const OOPString& getBasePath () const;

};



_OOPUTILS_END



#endif